<%@ page import="com.fhd.pojo.Recharge" %>
<%@ page import="com.fhd.constant.Constants" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.fhd.pojo.Merchant" %><%--
  Created by IntelliJ IDEA.
  User: 44252
  Date: 2025/3/29
  Time: 15:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商户审核管理</title>
</head>
<body>
<h2>
    以下是所有商户信息：
</h2>
<a href="<%=request.getContextPath()%>/manager.do?method=downloadMerchantExcel">导出商户信息表格</a>
<br>
<a href="<%=request.getContextPath()%>/jsp/managerFrame.jsp">返回管理员主页</a><br><br>
<%
    // 判断有无操作提示
    String message = (String) request.getSession().getAttribute(Constants.UPDATE_MERCHANT_APPLY_SITUATION_MESSAGE);
    if (message != null) {
        out.write("<h3 style=\"color: red\">" + message + "</h3>");
        request.getSession().removeAttribute(Constants.UPDATE_MERCHANT_APPLY_SITUATION_MESSAGE);
    }

    String object = (String) request.getSession().getAttribute(Constants.GET_ALL_MERCHANT_MESSAGE);
    // 判断控制层传的是信息还是对象
    if (object != null) {
        out.print("<h3 style=\"color: red\">" + object + "</h3>");
        request.getSession().removeAttribute(Constants.GET_ALL_MERCHANT_MESSAGE);
    } else {
        ArrayList<Merchant> merchants = (ArrayList<Merchant>) request.getSession().getAttribute(Constants.GET_ALL_MERCHANT_SESSION);
        if (merchants != null && !merchants.isEmpty()) {
            // 每一个商户，展示完信息后，在展示到申请状态时，都需要有选项，通过或者封禁，并且可以更改
            for (int i = 0; i < merchants.size(); i++) {
                Merchant merchant = merchants.get(i);
                out.print("商户编号：" + merchant.getId() + "<br>");
                out.print("商户用户名：" + merchant.getUserName() + "<br>");
                out.print("店铺名：" + merchant.getShopName() + "<br>");
                out.print("地址：" + merchant.getAddress() + "<br>");
                out.print("联系电话：" + merchant.getPhone() + "<br>");
                out.print("关键词：" + merchant.getKeyWord() + "<br>");
                out.print("工作时间：" + merchant.getWorkTimeBegin() + "~~~" + merchant.getWorkTimeEnd() + "<br>");
                int situation = merchant.getApplySituation();
                if (situation == 0) {
                    out.print("申请状态：等待确认<br>");
                } else if (situation == 1){
                    out.print("申请状态：已通过<br>");
                } else {
                    out.print("申请状态：被封禁<br>");
                }
%>
<form action="<%=request.getContextPath()%>/manager.do" method="post">
    <input type="hidden" name="method" value="changeMerchantAppluSituation">
    <input type="hidden" name="id" value="<%=merchant.getId()%>">
    <input type="submit" name="rechargeSituation" value="通过">
    <input type="submit" name="rechargeSituation" value="封禁">
</form>
<%
                out.print("=========================<br>");
            }
        }
    }
%>
</body>
</html>
